package com.huizu.pay.util;

import com.github.wxpay.sdk.WXPayConfig;
import com.huizu.pay.util.pay.wxpay.sdk.WxPayEnumConfig;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * 
 *
 */
public class MyAppConfig implements WXPayConfig {

    private byte[] certData;// 创建时间
    //app
    private String wx_app_appId = WxPayEnumConfig.app_appId;// 微信appId
    //小程序
    private String wx_appId = WxPayEnumConfig.wx_appId;// 微信appId


    private String app_mch_id = WxPayEnumConfig.mch_id;// 商户id
    private String app_private_key = WxPayEnumConfig.private_key;// 商户密钥
    //private String cert_file = "G:\\apiclient_cert.p12";// 退款证书
    private String cert_file = WxPayEnumConfig.cert_file;// 退款证书
    public MyAppConfig() throws Exception {
        String certPath = cert_file;
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }

    public String getAppID() {
        return wx_app_appId;
    }

    public String getMchID() {
        return app_mch_id;
    }

    public String getKey() {
        return app_private_key;
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }

}
